﻿define([
    "dojo/_base/declare",
    "gistech/widgets/baseWidget/BaseWidget",
    "dojo/text!./templates/Template.html",
    "dojo/_base/lang",
    "dojo/dom-style",
    "dojo/dom-construct",
    "dojo/on",
    "dojo/_base/connect"
    ],
    function(declare,BaseWidget,template,lang,style,domConstruct,on,eventconnect){
        return declare([BaseWidget],{

            isClose:false,

            postMixInProperties:function () {
                var baseDialogTemplateStr = template;
                this.templateString = baseDialogTemplateStr.replace("{content}", this.templateString);
                this.inherited(arguments);
            },

            resetAttr:function(){},

            postCreate:function () {
            	eventconnect.connect(this.btnClose, "onclick", this, this.closeDialog);
            },

            setTitle:function (title) {
                this.headTitle.innerHTML = title;
            },

            closeDialog:function () {
                var def = this.onBeforeClose();
                if (def && def.then) {
                    def.then(dojo.hitch(this, this.onClose));
                }
                else {
                    this.onClose();
                }
            },

            //关闭之前事件
            onBeforeClose:function () {

            },

            //关闭之后事件
            onAfterClose:function () {
                this.resetAttr();
            },

            //关闭事件
            onClose:function () {
                this.isClose = true;
                this.destroyRecursive();
                this.onAfterClose();
            }
    });
});
